import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GroupMemberData } from "../arenaCrossData/GroupMemberData";
import { PlayerUtil } from "../../common/util/PlayerUtil";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
import { GroupPlayerTips } from "../groupMatch/GroupPlayerTips";
import { CareerConfig } from "../../../resource/CareerConfig";
import { Cache } from "../../../cache/Cache";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { SArenaCrossGroupMember } from "../../../../../Message/Public/SArenaCrossGroupMember";
//class ArenaCrossGroupPlayerCellRenderer
    
    export  class ArenaCrossGroupPlayerCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat1);
            this._btnPlayer = ObjCreate.createGButton("", 0, 7, 195, 28, this, "LinkButton");
            this._btnPlayer.addEventListener(flash.events.MouseEvent.CLICK, this.onClickPlayer);
            this._tfCareer = ObjCreate.createTextField("", 195, 14, 95, 20, this, loc1);
            this._tfLevel = ObjCreate.createTextField("", 290, 14, 90, 20, this, loc1);
            this._tfCombat = ObjCreate.createTextField("", 380, 14, 90, 20, this, loc1);
            ObjCreate.createBg(0, 43, 470, 2, this, "SplitLine");
            return;
        }

        /* internal  */onClickPlayer(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetArenaCrossPlayerInfo, this._arenaCrossGroupMember.entityId));
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "groupmemberdata") 
            {
                this._groupMemberData = arg1 as GroupMemberData;
                this._arenaCrossGroupMember = this._groupMemberData.arenaCrossGroupMember;
                this.updateView();
            }
            return;
        }

        protected updateView(): void
        {
            if (this._arenaCrossGroupMember) 
            {
                this._btnPlayer.label = PlayerUtil.getProxyAndNameByEntityIdAndName(this._arenaCrossGroupMember.entityId, this._arenaCrossGroupMember.name);
                this._btnPlayer.toolTipData = this._groupMemberData;
                ToolTipsManager.register(this._btnPlayer, GroupPlayerTips, this._groupMemberData);
                this._tfCareer.text = CareerConfig.instance.getInfoByCode(this._arenaCrossGroupMember.career).name;
                this._tfLevel.text = this._arenaCrossGroupMember.level.toString();
                this._tfCombat.text = this._arenaCrossGroupMember.warfare.toString();
                if (this._arenaCrossGroupMember.entityId.typeEx == Cache.instance.role.entityInfo.entityId.typeEx && this._arenaCrossGroupMember.entityId.typeEx2 == Cache.instance.role.entityInfo.entityId.typeEx2) 
                {
                    this._btnPlayer.styleName = "LinkButton";
                }
                else 
                {
                    this._btnPlayer.styleName = "LinkButtonWhite";
                }
            }
            return;
        }

        /* internal */ /* var */_btnPlayer: GButton;

        /* internal */ /* var */_tfCareer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCombat: Object /* flash.text.TextField */;

        /* internal */ /* var */_isResCompl: Boolean=false;

        /* internal */ /* var */_arenaCrossGroupMember: SArenaCrossGroupMember;

        /* internal */ /* var */_groupMemberData: GroupMemberData;
    }
